package com.woniu.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

public class CodeGeneratorUtil {

    // 用户编号前缀
    private static final String USER_CODE_PREFIX = "EMPLOYEE";
    // 任务信息前缀
    private static final String TASK_CODE_PREFIX = "TASK";
    // 报警消息前缀
    private static final String ALARM_CODE_PREFIX = "ALARM";

    //待处理
    public static final String PENDING_PROCESSING = "待处理";
    //已处理
    public static final String TASK_STATUS = "在线";

    public static final Integer PERSON_STATUS = 1;
    /**
     * 生成用户编号
     * 规则: "USR" + 时间戳(yyyyMMddHHmmss) + 4位随机数
     * 示例: USR202502161530309876
     */
    public static String generateEmpLoyeeCode() {
        Random random = new Random();
        int index = random.nextInt(1000) + 1;

        return USER_CODE_PREFIX + "_" + index;
    }

    public static String generateTaskCode() {
        // 获取当前时间戳
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String timestamp = sdf.format(new Date());

        Random random = new Random();
        int index = random.nextInt(1000) + 1;

        return TASK_CODE_PREFIX + "_" + timestamp + index;
    }

    public static String generateAlarmCode() {
        // 获取当前时间戳
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String timestamp = sdf.format(new Date());

        Random random = new Random();
        int index = random.nextInt(1000) + 1;

        return ALARM_CODE_PREFIX + "_" + timestamp + index;
    }
}
